package com.ptu.controller.admin;

import com.ptu.dto.CommentDTO;
import com.ptu.dto.CommentListDTO;
import com.ptu.mapper.CommentMapper;
import com.ptu.server.CommentServer;
import com.ptu.util.PageResult;
import com.ptu.util.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

@RestController("adminCommentController")
@RequestMapping("/admin/comment")
@Tag(name = "管理员评论模块")
public class CommentController {

    @Autowired
    CommentMapper commentMapper;

    @Autowired
    CommentServer commentServer;

    @Operation(summary = "评论列表")
    @RequestMapping("/list")
    public Result<PageResult> list(@RequestBody CommentListDTO commentListDTO) {
        System.out.println("分页订单");
        PageResult pageResult = commentServer.getCommentList(commentListDTO);
        return Result.success(pageResult);
    }

    @Operation(summary = "删除评论")
    @RequestMapping("/delete")
    public Result<Void> delete(@PathVariable Integer id) {
        commentMapper.deleteComment(id);
        return Result.success();
    }

    @PostMapping("/update")
    @Operation(summary = "修改评论")
    public Result<Void> updateComment(@RequestBody CommentDTO commentDTO) {
        System.out.println("修改评论");
        commentServer.updateComment(commentDTO);
        return Result.success();
    }
}
